{% extends "../../../layui/layouts/main.html" %}

{% block mainbody %}
<div id="menu-index">

    {% include "_search.tpl" %}

    <div class="layui-card">
        <div class="layui-card-header yak-card-header">
            {{Header}}
        </div>
        <div class="layui-card-body">
            <table id="drug-table" lay-filter="drug-table-filter"></table>
        </div>
    </div>

</div>
{% endblock %}

{% block script %}
<script>
    layui.use(['grid', 'layarea', 'laydate'], function () {
        var pager = layui.grid
            , layarea = layui.layarea
            , laydate = layui.laydate
            , tableId = "drug-table"
            , tableFilter = "drug-table-filter"
            , searchFilter = "drug-search"
            , cols = [
            {width: 60, field: "_serial", title: "序号"},
            {width: 170, field: "number", title: "上报编号", event: "detail", style: "color:blue"},
            {field: "title", title: "药品名称"},
            {field: "category", title: "药品类别"},
            {field: "risk", title: "风险累及系统-器官"},
            {width: 170, field: "reported_at", title: "上报时间", sort: true},
            {field: "unit", title: "上报单位"},
            {field: "address", title: "所属地区"},
            {field: "phone", title: "联系电话"},
            {field: "remark", title: "备注"},
            {width: 170, field: "checked_at", title: "处理时间", sort: true},
            // {field: "status", title: "处理状态"},
            {field: "comment", title: "风险评价"},
        ]
            , table = {
            "id": tableId,
            "elem": "#" + tableId,
            "limit": 8,
            "limits": [10, 20, 50, 100],
            "cols": [cols],
            "method": "post",
            "request": {"pageName": "page", "limitName": "per-page"},
            "url": "/report-summary",
            "toolbar": "#toolBar",
            "page": {"hash": "fenye"},
            "autoSort": false,
            "defaultToolbar": ["filter", "print", {
                "title": "导出Excel",
                "layEvent": "OUTPUT_EXCEL",
                "icon": "layui-icon-export"
            }]
        }
            , eventOptions = {
                "detail": {"url": "/report-summary/view", "open": "iframe", "openRefresh": true},
                "OUTPUT_EXCEL": {"url": "/report-summary/excel", "filename": "药品风险汇总"}
            }
            , events = {}

        layarea.render({
            elem: '#'+ searchFilter,
            change: function (res) {
                //选择结果
                console.log(res)
            }
        });

        laydate.render({
            elem: '#yak_dt_s',
            trigger: 'click'
        });

        laydate.render({
            elem: '#yak_dt_e',
            trigger: 'click'
        });

        pager.render({
            "searchFilter": searchFilter,
            "tableId": tableId,
            "tableFilter": tableFilter,
            "sort": "server",
            "countCache": true,
            "table": table,
            "editor": {},
            "eventOptions": eventOptions
        }, events)
    })
</script>
{% endblock %}